﻿package tests
{
	import com.onlyMe.serialization.IsleDeserializer;
	import com.onlyMe.serialization.IsleSerializer;
	
	import flash.display.Sprite;
	import flash.utils.ByteArray;
	
	/**
	 * @author ariel
	 */
	public class SerializationTest extends Sprite
	{
		public function SerializationTest():void
		{
			init();
		}
		
		private function init():void
		{
			var serializer:IsleSerializer = new IsleSerializer();
			
			for (var i:int = 1; i < 10; i++)
			{
				var ba:ByteArray = new ByteArray();
				for (var j:int = 0; j < i*i; j++)
				{
					ba.writeByte(100+j);
				}
				serializer.append(ba);
			}
			
			var bytes:ByteArray = serializer.flush();
			bytes.compress();
			serializer.destroy();
			
			var deserializer:IsleDeserializer = new IsleDeserializer();
			bytes.uncompress();
			deserializer.deserialize(bytes);
			
			while (deserializer.hasNext()) {
				ba = deserializer.getNext();
				trace(ba.toString());
			}
		}
	}
	
}
